<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>添加用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
      <script type="text/javascript" src="../../lib/jquery/jquery-3.0.0.min.js"></script>
      <script src="../../lib/layui/layui.js" charset="utf-8"></script>
      <script src="../../static/js/app.js"></script>
      <script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script>
      <script src="../../static/js/common/optUtils.js"></script>
      <link rel="stylesheet" href="../../static/css/font.css">
<link rel="stylesheet" href="../../lib/layui/css/layui.css">
      <link rel="stylesheet" href="../../static/css/weadmin.css">
      <link rel="stylesheet" href="../../lib/formselect/formSelects-v4.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="weadmin-body">
        <form class="layui-form" id="FirstForm">
            <input id="resJobStatus" name="resJobStatus" type="hidden">
            <input id="id" name="id" type="hidden">
            <input id="createTime" name="createTime" type="hidden">
          <div class="layui-form-item">
              <label for="beanName" class="layui-form-label">
                  <span class="we-red">*</span>bean名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="beanName" name="beanName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="methodName" class="layui-form-label">
                  <span class="we-red">*</span>方法名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="methodName" name="methodName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
            <div class="layui-form-item">
                <label for="methodParams" class="layui-form-label">
                    <span class="we-red">*</span>方法参数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="methodParams" name="methodParams"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
          <div class="layui-form-item">
              <label class="layui-form-label">
                  <span class="we-red">*</span>cron表达式
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="cronExpression" name="cronExpression" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="we-red">*</span>
              </div>
          </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="we-red">*</span>状态
                </label>
                <div class="layui-input-inline">
                    <input type="radio" name="jobStatus" value="1" title="正常" checked>
                    <input type="radio" name="jobStatus" value="0" title="暂停">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="we-red">*</span>备注
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="remark" name="remark"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
          <div class="layui-form-item">
              <button id="addbtn" class="layui-btn" lay-filter="add" lay-submit="">提交</button>
          </div>
      </form>
    </div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
        var act = GetUrlParam("act");
    		layui.extend({
					admin: '{/}../../static/js/admin'
				});

            layui.config({
                base: '../../lib/formselect/' //此处路径请自行处理, 可以使用绝对路径
            }).extend({
                formSelects: 'formSelects-v4.min'
            });
        layui.use(['form','layer','admin','jquery','laydate','formSelects'], function(){
          var form = layui.form,
          	admin = layui.admin,
              laydate=layui.laydate,
          	layer = layui.layer,
              formSelects = layui.formSelects,
          $=layui.jquery;
            if (act=='edit'){
                var data1 =JSON.parse(sessionStorage.getItem('editRowData'));
                for (var o in data1){
                    if (o=='jobStatus') {
                        $('#resJobStatus').val(data1[o]);
                        var radio = document.getElementsByName("jobStatus");
                        var radioLength = radio.length;
                        for (var i = 0; i < radioLength; i++) {
                            if (data1[o] == radio[i].value) {
                                $(radio[i]).next().click();
                            }
                        }
                    }else {
                        $("#"+o).val(data1[o]);
                    }
                };
            }
            formSelects.render('selectId');
          	form.render();
          //监听提交
         $("#addbtn").on("click",function () {
             form.on('submit(add)',function (data) {
                var f= data.field;
                if (act=='edit'){
                    new APIRequest(
                        {
                            url: global.api_url + "/sysJobPo/editJob",
                            header: {content_type: "application/json;charset=UTF-8",Authorization:getUser().token},
                            data:f,
                            method: "Post",
                            async: false,
                            success: function (result) {
                                parent.location.reload();//刷新父页面
                                parent.layui.admin.events.closeThisTabs();//关闭当前页面
                                layer.msg("更改任务成功");
                            },
                            dataType: "json"
                        }
                    );
                } else {;
                    new APIRequest(
                        {
                            url: global.api_url + "/sysJobPo/addJob",
                            header: {content_type: "application/json;charset=UTF-8",Authorization:getUser().token},
                            data:f,
                            method: "Post",
                            async: false,
                            success: function (result) {
                                parent.location.reload();//刷新父页面
                                parent.layui.admin.events.closeThisTabs();//关闭当前页面
                                layer.msg("新增用户成功");
                            },
                            dataType: "json"
                        }
                    );
                }
                 return false;
             });
         })
        });
    </script>
  </body>

</html>